<?php
use doumiaoduo\layer\LayerAsset;
use doumiaoduo\layer\LayerIframeWidget;
LayerAsset::register($this);
LayerIframeWidget::widget();
?>

<div class="yx-praise-list-box yx-praise-box yx-radius2 zx-min-height">
    <div class="query-box">
        <input type="text" name="card" class="seachInput" placeholder="输入会员卡号/手机号或者刷卡">
        <input type="hidden" id="JumpUrl" value="<?=\common\components\helpers\Fun::url(['customer/details'])?>">
        <input type="hidden" id="RequestUrl" value="<?=\common\components\helpers\Fun::url(['customer/query'])?>">
        <button type="button" class="seachBtn">查询</button>
    </div>
</div>
<?php
$js=<<<JS
  $('.seachInput').focus();
   layer.config({
        extend: ['skin/customskin/style.css']//加载您的扩展样式
    });
     $(document).on('click','.seachBtn',function(){
        var card = $.trim($('.seachInput').val());
        if(card.length == 0){
            $('.seachInput').focus();
             layer.msg('请输入卡号或手机号！',{id:'layer-msg',skin: 'layui-msg-customskin',time: 1000}); return false;
        }
         var JumpUrl = $('#JumpUrl').val();
         var RequestUrl = $('#RequestUrl').val();
          $.post(RequestUrl, {card: card,ajax:'card',_csrf:yii.getCsrfToken()}, function (data) {
              if(data.status == 1){
                  window.location.href=JumpUrl+'?id='+data.id;
              }else{
                  $('.seachInput').val('').focus();
                  layer.msg('此会员不存在！',{id:'layer-msg',skin: 'layui-msg-customskin',time: 1000}); return false;
              }
           }, "json");
     });

    $('.seachInput').keydown(function (event) {
        var card = $.trim($('.seachInput').val());
         if (event.keyCode == 13 && card != 0) {
               $('.seachBtn').click();
         }
    });
JS;
\Yii::$app->view->registerJs($js);
?>

